#ifndef MIPSSIGNALHANDLER_H
#define MIPSSIGNALHANDLER_H

#include "crossbit/SignalHandler.h"
#include "crossbit/SignalRegister.h"
#include <signal.h>
#include "arch/mips/MIPSSignalInternal.h"

namespace crossbit {

    //class ProcessorState;
    //class MemoryImage;
	//class SignalHandler;

    class MIPSSignalHandler : public SignalHandler {
        public:
            MIPSSignalHandler(ProcessorState	*processor_state,
							  MemoryImage		*memory_image, 
							  MemoryManager		*memory_manager,
							  TraceManager		*trace_manager,
						      Interpreter		*interpreter, 
							  VBlockBuilder 	*builder, 
						      TCache 			*tcache,
							  Translator 		*translator,
						      SyscallHandler	*syscall_handler,
							  SignalRegister	*signal_register)
						: SignalHandler(processor_state,
										memory_image,
										memory_manager,
										trace_manager,
										interpreter,
										builder,
										tcache,
										translator,
										syscall_handler,
										signal_register)
			{

				sig_rg->setHandler((XTMemAddr)signal_handler,
								   (XTMemAddr)rt_signal_handler,
								   (XTMemAddr)sigaction_handler,
								   (XTMemAddr)rt_sigaction_handler);
		
			}	


            ~MIPSSignalHandler();

			static void signal_handler(XTInt32 local_sig_num);
			static void rt_signal_handler(XTInt32 local_sig_num);
			static void sigaction_handler(XTInt32 local_sig_num, struct siginfo *local_sig_info, void *unused);		
			static void rt_sigaction_handler(XTInt32 local_sig_num, struct siginfo *local_sig_info, void *unused);	
			
			static XTInt32 convertSigNum2Scr(XTInt32 local_sig_num);
			static void doSignal(XTMemAddr sig_entry);
    };

}
#endif
